home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / RELEASE.ZIP / sub_arctic / test / frame_test2.java < prev    next >
Encoding:
Java Source  |  1996-10-04  |  3.2 KB  |  112 lines

  1. package sub_arctic.test;
  2.  
  3. import sub_arctic.input.*;
  4. import sub_arctic.lib.*;
  5. import sub_arctic.output.*;
  6. import sub_arctic.constraints.std_function;
  7.  
  8. /**
  9.  * We are going to make a separate applet this time. This applet gets
  10.  * embedded in a frame popped up by the main applet.
  11.  */
  12. class frame_test_applet extends interactor_applet implements callback_object {
  13.   public void build_ui(base_parent_interactor top) {
  14.     button hide_button;
  15.  
  16.     /* put the button at 10, 10 and use 10 and 10 as the border sizes */
  17.     hide_button=new button("Push Me Too!", this);
  18.     top.add_child(hide_button);
  19.     hide_button.set_x_constraint(std_function.centered(PARENT.X2(), 0));
  20.     hide_button.set_y_constraint(std_function.centered(PARENT.Y2(),0));
  21.   }
  22.   /**
  23.    * Called when they press the button 
  24.    */
  25.   public void callback(interactor from_obj, event evt, int callback_num, 
  26.                Object callback_info) {
  27.  
  28.     System.out.println("Pressed the extra button");
  29.   }
  30. }
  31.  
  32. /**
  33.  * This is the main applet.
  34.  */
  35. public class frame_test2 extends interactor_applet implements callback_object 
  36. {
  37.   button show_button;
  38.   interactor_frame iframe;
  39.  
  40.   public void build_ui(base_parent_interactor top) {
  41.     /* put a button in */
  42.     show_button=new button(0,0,"Push Me", this);
  43.     top.add_child(show_button);
  44.     /* center the button */
  45.     show_button.set_x_constraint(std_function.centered(PARENT.X2(), 0));
  46.     show_button.set_y_constraint(std_function.centered(PARENT.Y2(), 0));
  47.   }
  48.   /**
  49.    * This gets called if we get uniconified, so we need to put the
  50.    * frame back on the screen.
  51.    */
  52.   public void start() {
  53.     if (iframe!=null) {
  54.       iframe.show();
  55.     }
  56.   }
  57.   /**
  58.    * You get a call to stop if the browser gets iconified.  We take
  59.    * the window off the screen.
  60.    */
  61.   public void stop() {
  62.     if (iframe!=null) {
  63.       iframe.hide();
  64.     }
  65.   }
  66.   /**
  67.    * Create the extra frame.
  68.    */
  69.   public void newFrame() {
  70.     /* if we already have a frame, don't need another one */
  71.     if (iframe!=null) {
  72.       return;
  73.     }
  74.     
  75.     iframe=new interactor_frame("Test Frame", new frame_test_applet(),
  76.                 200,150);
  77.     /* if you called "setResizable() on iframe here you could force it
  78.      * to never get bigger */
  79.     iframe.set_callback_obj(this);
  80.     iframe.show();
  81.   }
  82.   /**
  83.    * Called when they press the button 
  84.    */
  85.   public void callback(interactor from_obj, event evt, int callback_num, 
  86.                Object callback_info) {
  87.     /* figure out who sent this */
  88.     if (from_obj==show_button) {
  89.       newFrame();
  90.     } else {
  91.       /* must be the top level telling use the user killed us */
  92.       iframe=null;
  93.     }
  94.   }
  95. }
  96. /*=========================== COPYRIGHT NOTICE ===========================
  97.  
  98. This file is part of the subArctic user interface toolkit.
  99.  
  100. Copyright (c) 1996 Scott Hudson and Ian Smith
  101. All rights reserved.
  102.  
  103. The subArctic system is freely available for most uses under the terms
  104. and conditions described in 
  105.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  106. and appearing in full in the lib/interactor.java source file.
  107.  
  108. The current release and additional information about this software can be 
  109. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  110.  
  111. ========================================================================*/
  112.